home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DBVGAL17.ARJ / DEMOS.ARJ / VGAREGS.C < prev    next >
Text File  |  1992-01-26  |  7KB  |  184 lines

  1. #include <dos.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "vidlib.h"
  5.  
  6. char *CRTCdregnames[] = { "Horizontal total", "Horizontal display enable end",
  7.      "Start horizontal blanking", "End horizontal blanking",
  8.      "Start horizontal retrace", "End horizontal retrace", "Vertical total",
  9.      "Overflow", "Preset row scan", "Maximum scan line address",
  10.      "Cursor start", "Cursor end", "Start address high", "Start address low",
  11.      "Cursor location high", "Cursor location low", "Vertical retrace start",
  12.      "Vertical retrace end", "Vertical display enable end",
  13.      "Offset (logical line width)", "Underline location",
  14.      "Start vertical blanking", "End vertical blanking", "Mode Control",
  15.      "Line compare"
  16. };
  17.  
  18. char *Sequencernames[] = { "Reset", "Clocking mode", "Map mask",
  19.      "Character map select", "Memory mode"
  20. };
  21.  
  22. char *GCdregnames[] = { "Set/reset", "Enable set/reset",
  23.      "Color compare", "Data rotate/function select",
  24.      "Read map select", "Graphics mode", "Miscellaneous",
  25.      "Color don't care", "Bit mask"
  26. };
  27.  
  28. char *ACdregnames[] = { "Attribute mode control", "Border color",
  29.      "Color plane enable", "Horizontal pixel panning", "Color select"
  30. };
  31.  
  32. /* ---------------------------- m a i n ----------------------------------- */
  33. void main(void)
  34. {
  35.    int i, temp1, temp2, temp3, vrs, svb;
  36.    unsigned char v, overflow, ehr, msl, shb, shr;
  37.    union REGS r;
  38.  
  39.    r.h.ah=0x0f;
  40.    int86(0x10, &r, &r);  /* get video mode */
  41.    printf("Current video mode = %02hx\n", r.h.al);
  42.  
  43.    printf("\nSequencer registers:\n");
  44.    printf("-----------------------------------------------\n");
  45.    for (i=0; i<5; i++) {
  46.        v=SQread_reg(i);
  47.        printf("%2hxh: %02hxh  %3hu  :%s\n",i,v,v,Sequencernames[i]);
  48.    }
  49.  
  50.    printf("\nMiscellaneous output register\n");
  51.    printf("   : %02hxh       :\n", v=MOread_reg());
  52.  
  53.  
  54.    overflow=CRTCread_reg(7);  /* overflow: many different calculations */
  55.  
  56.    printf("\nCRTC data register contents:\n");
  57.    printf("-----------------------------------------------\n");
  58.  
  59.    v=CRTCread_reg(0);
  60.    printf("%2hxh: %02hxh  %3hu  :%s (+5= %3hu)\n",0,v,v,CRTCdregnames[0],v+5);
  61.  
  62.    v=CRTCread_reg(1);
  63.    printf("%2hxh: %02hxh  %3hu  :%s\n",1,v,v,CRTCdregnames[1]);
  64.  
  65.    shb=v=CRTCread_reg(2);
  66.    printf("%2hxh: %02hxh  %3hu  :%s\n",2,v,v,CRTCdregnames[2]);
  67.  
  68.    v=CRTCread_reg(3); ehr=CRTCread_reg(5);
  69.    temp1=(shb%64); temp2=(v%32+(ehr & 0x80)/4);
  70.    if (temp2 > temp1)
  71.       temp3=(shb&0xc0)+temp2;
  72.    else
  73.       temp3=(shb&0xc0)+temp2+64;
  74.    printf("%2hxh: %02hxh  %3hu  :%s (= %3hu)\n",3,v,v,CRTCdregnames[3],temp3);
  75.  
  76.    shr=v=CRTCread_reg(4);
  77.    printf("%2hxh: %02hxh  %3hu  :%s\n",4,v,v,CRTCdregnames[4]);
  78.  
  79.    temp1=(shr&0xe0); temp2=(ehr%32); temp3=temp1+temp2;
  80.    if (temp3 < shr) temp3+=32;
  81.    printf("%2hxh: %02hxh  %3hu  :%s (= %3hu)\n",
  82.                   5,ehr,ehr,CRTCdregnames[5],temp3);
  83.    v=CRTCread_reg(6);
  84.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",
  85.                   6,v,v,CRTCdregnames[6],
  86.                   (int)(v+(overflow&0x20)*16+(overflow&0x01)*256));
  87.  
  88.    v=overflow;
  89.    printf("%2hxh: %02hxh  %3hu  :%s\n",7,v,v,CRTCdregnames[7]);
  90.    printf("   : Bit 9 :%1u - Vertical Retrace start\n",
  91.                   (overflow&0x80)/128);
  92.    printf("   : Bit 9 :%1u - Vertical Display enable end\n",
  93.                   (overflow&0x40)/64);
  94.    printf("   : Bit 9 :%1u - Vertical Total\n",
  95.                   (overflow&0x20)/32);
  96.    printf("   : Bit 8 :%1u - Line compare\n",
  97.                   (overflow&0x10)/16);
  98.    printf("   : Bit 8 :%1u - Start vertical blank\n",
  99.                   (overflow&0x08)/8);
  100.    printf("   : Bit 8 :%1u - Vertical Retrace start\n",
  101.                   (overflow&0x04)/4);
  102.    printf("   : Bit 8 :%1u - Vertical Display enable end\n",
  103.                   (overflow&0x02)/2);
  104.    printf("   : Bit 8 :%1u - Vertical Total\n", (overflow&0x01));
  105.  
  106.    v=CRTCread_reg(8);
  107.    printf("%2hxh: %02hxh  %3hu  :%s\n",8,v,v,CRTCdregnames[8]);
  108.    msl=v=CRTCread_reg(9);
  109.    printf("%2hxh: %02hxh  %3hu  :%s (= %3hu)\n",9,v,v,CRTCdregnames[9],v%32);
  110.    if (v&0x80) printf("   :           :double scan set to 1\n");
  111.       else     printf("   :           :double scan set to 0\n");
  112.    for (i=10; i<16; i++) {
  113.        v=CRTCread_reg(i);
  114.        printf("%2hxh: %02hxh  %3hu  :%s\n",i,v,v,CRTCdregnames[i]);
  115.    }
  116.    v=CRTCread_reg(16);
  117.    vrs=v+(overflow&0x80)*4+(overflow&0x04)*64;
  118.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",16,v,v,CRTCdregnames[16],
  119.                   vrs);
  120.  
  121.    v=CRTCread_reg(17);
  122.    temp1=(vrs&0xfff0); temp2=(v%16); temp3=temp1+temp2;
  123.    if (temp3 < vrs) temp3+=16;
  124.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",17,v,v,CRTCdregnames[17],
  125.                   temp3);
  126.    if (v&0x80)
  127.      printf("   :           :CRTC registers 0 to 7 write protected.\n");
  128.    else
  129.      printf("   :           :CRTC registers 0 to 7 not write protected.\n");
  130.    printf("   :           :Refresh Cycle Select=%1u\n",(v&0x40)/64);
  131.    printf("   :           :(not)Enable vertical interrupt=%1u\n",
  132.                (v&0x20)/32);
  133.    printf("   :           :(not)Clear vertical interrupt=%1u\n",
  134.                (v&0x10)/16);
  135.  
  136.    v=CRTCread_reg(0x12);
  137.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",18,v,v,CRTCdregnames[18],
  138.                   v+(overflow&0x40)*8+(overflow&0x02)*128);
  139.    v=CRTCread_reg(0x13);
  140.    printf("%2hxh: %02hxh  %3hu  :%s\n",19,v,v,CRTCdregnames[19]);
  141.    v=CRTCread_reg(0x14);
  142.    printf("%2hxh: %02hxh  %3hu  :%s (= %3hu)\n",20,v,v,CRTCdregnames[20],
  143.                   v%32);
  144.    printf("   :           :Double word mode=%1u\n",(v&0x40)/64);
  145.    printf("   :           :Count by 4 mode=%1u\n", (v&0x20)/32);
  146.  
  147.    v=CRTCread_reg(0x15);
  148.    svb=v+(msl&0x20)*16+(overflow&0x08)*32;
  149.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",21,v,v,CRTCdregnames[21],svb);
  150.    v=CRTCread_reg(0x16);
  151.    temp1=(svb&0xff00); temp3=temp1+v;
  152.    if (temp3 < svb) temp3+=256;
  153.    printf("%2hxh: %02hxh  %3hu  :%s (= %3d)\n",
  154.                   22,v,v,CRTCdregnames[22],temp3);
  155.  
  156.    v=CRTCread_reg(0x17);
  157.    printf("%2hxh: %02hxh  %3hu  :%s ()\n",23,v,v,CRTCdregnames[23]);
  158.    v=CRTCread_reg(0x18);
  159.    printf("%2hxh: %02hxh  %3hu  :%s ()\n",24,v,v,CRTCdregnames[24]);
  160.  
  161.  
  162.    printf("\nAttribute controller registers:\n");
  163.    printf("-----------------------------------------------\n");
  164.    for (i=0; i<16; i++) {
  165.        v=ACread_reg(i);
  166.        printf("%2hxh: %02hxh  %3hu  :Palette color #%d\n",i,v,v,i);
  167.    }
  168.    for (i=16; i<0x15; i++) {
  169.        v=ACread_reg(i);
  170.        printf("%2hxh: %02hxh  %3hu  :%s\n",i,v,v,ACdregnames[i-16]);
  171.    }
  172.  
  173.    printf("\nGraphics controller registers:\n");
  174.    printf("-----------------------------------------------\n");
  175.    for (i=0; i<9; i++) {
  176.        v=GCread_reg(i);
  177.        printf("%2hxh: %02hxh  %3hu  :%s\n",i,v,v,GCdregnames[i]);
  178.    }
  179.  
  180.    printf("\n");
  181.    exit(0);
  182.  
  183. }
  184.